/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("V_PLAN_WORK_ORDER",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.System.IServices;
using VOL.Core.Enums;
using VOL.Core.Filters;

namespace VOL.System.Controllers
{
    public partial class V_PLAN_WORK_ORDERController
    {
        private readonly IV_PLAN_WORK_ORDERService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public V_PLAN_WORK_ORDERController(
            IV_PLAN_WORK_ORDERService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        ///// <summary>
        ///// api加上属性 [ApiTask]
        ///// </summary>
        ///// <returns></returns>
        //[ApiTask]
        //[HttpGet, HttpPost, Route("test")]
        //public IActionResult Test()
        //{
        //    return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
        //}

        /// <summary>
        /// api加上属性 [ApiTask]
        /// </summary>
        /// <returns></returns>
        [ApiTask]
        [HttpGet, HttpPost, Route("taskTest")]
        public IActionResult TaskTest()
        {
            return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
        }

        /// <summary>
        /// 手动执行一次
        /// </summary>
        /// <param name="taskOptions"></param>
        /// <returns></returns>
        [Route("start"), HttpPost]
        [ActionPermission(ActionPermissionOptions.Update)]
        public async Task<object> Run([FromBody] Sys_QuartzOptions taskOptions)
        {
            return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
           // return await Service.Run(taskOptions);
        }
        #region by guoyuguo 2024.11.5 停止
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="taskOptions"></param>
        /// <returns></returns>
        [Route("start1"), HttpPost]
        [ActionPermission(ActionPermissionOptions.Update)]
        public async Task<object> Start([FromBody] MANU_EXECUTION taskOptions)
        {
            return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
            // return await Service.Run(taskOptions);
        }
        /// <summary>
        /// 暂停
        /// </summary>
        /// <param name="taskOptions"></param>
        /// <returns></returns>
        [Route("pause"), HttpPost]
        [ActionPermission(ActionPermissionOptions.Update)]
        public async Task<object> Pause([FromBody] MANU_EXECUTION taskOptions)
        {
            return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
            // return await Service.Run(taskOptions);
        }
        /// <summary>
        /// 紧急暂停
        /// </summary>
        /// <param name="taskOptions"></param>
        /// <returns></returns>
        [Route("stop"), HttpPost]
        [ActionPermission(ActionPermissionOptions.Update)]
        public async Task<object> Stop([FromBody] MANU_EXECUTION taskOptions)
        {
            return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
            // return await Service.Run(taskOptions);
        }
        /// <summary>
        /// 终止
        /// </summary>
        /// <param name="taskOptions"></param>
        /// <returns></returns>
        [Route("termination"), HttpPost]
        [ActionPermission(ActionPermissionOptions.Update)]
        public async Task<object> Termination([FromBody] MANU_EXECUTION taskOptions)
        {
            return Content(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
            // return await Service.Run(taskOptions);
        }

        #endregion
        ///// <summary>
        ///// 手动执行一次
        ///// </summary>
        ///// <param name="taskOptions"></param>
        ///// <returns></returns>
        //[Route("run"), HttpPost]
        //[ActionPermission(ActionPermissionOptions.Update)]
        //public async Task<object> Run([FromBody] Sys_QuartzOptions taskOptions)
        //{
        //    return await Service.Run(taskOptions);
        //}
        ///// <summary>
        ///// 开启任务
        ///// </summary>
        ///// <param name="schedulerFactory"></param>
        ///// <param name="taskOptions"></param>
        ///// <returns></returns>
        //[Route("start"), HttpPost]
        //[ActionPermission(ActionPermissionOptions.Update)]
        //public async Task<object> Start([FromBody] Sys_QuartzOptions taskOptions)
        //{
        //    return await Service.Start(taskOptions);
        //}

        ///// <summary>
        ///// 暂停任务
        ///// </summary>
        ///// <param name="schedulerFactory"></param>
        ///// <param name="taskOptions"></param>
        ///// <returns></returns>
        //[Route("pause"), HttpPost]
        //[ActionPermission(ActionPermissionOptions.Update)]
        //public async Task<object> Pause([FromBody] Sys_QuartzOptions taskOptions)
        //{
        //    return await Service.Pause(taskOptions);
        //}
    }
}
